Prompts
Prompts define the instructions and behavioral guidance that shape how BindAI agents operate. At the simplest level, prompts can be provided through an agent’sinstructions configuration.
For larger applications, prompt content can be separated from application logic and reused across multiple agents.
What Is a Prompt?
A prompt provides the information and instructions an AI model needs to perform a task. Instructions can define:- The agent’s role
- Expected behavior
- Tone and style
- Constraints
- Output requirements
- Domain-specific rules
- How tools or retrieved information should be used
Using Instructions
The simplest way to configure an agent’s behavior is withinstructions.
Static Instructions
A static instruction remains the same for every execution.- Customer support assistants
- Technical writers
- Research assistants
- Coding assistants
- Document reviewers
Dynamic Context
Many applications need to provide runtime information to an agent. For example:- User input
- Conversation state
- Memory
- Knowledge
- Retrievers
- Tools
- Workflow state
- Execution context
Prompt Composition
Large instruction sets are easier to maintain when organized into logical sections. A structured prompt might contain:Role Instructions
A prompt can establish the role an agent should perform. For example:Behavioral Instructions
Behavioral instructions define how the agent should respond. For example:Output Instructions
Prompts can explicitly describe the expected output format. For example, Markdown:Structured Output and Prompts
Prompts and structured output solve different parts of the same problem. The prompt can explain what information should be generated:Reusing Instructions
Instructions can be reused through shared Python configuration. For example:Keeping Prompts Separate from Application Logic
For larger applications, avoid putting large instruction blocks throughout application code. Prompt definitions can be stored in dedicated files or modules. For example:- Review
- Version
- Test
- Reuse
- Update independently from application logic
Agent.builder().instructions(...).
The exact loading mechanism is an application design choice.
File-Based Prompt Example
A project can keep prompt content in a text or Markdown file. For example:Prompt Variables
Applications sometimes need to incorporate runtime values into instructions. For example:- User input for the current request
- Conversation for conversational context
- Memory for persisted information
- Knowledge and retrieval for external information
- Tools for external operations
- Workflow state for multi-step execution
Prompts and Conversation
Prompt instructions and conversation input serve different purposes. Conceptually, an agent execution combines:Prompts and Memory
Memory is an agent capability that can provide persisted information during execution. For example:- Prompt — defines agent behavior and instructions.
- Memory — provides stored information.
- Conversation — provides conversational context.
- User input — provides the current request.
Prompts and Knowledge
Knowledge and retrieval provide external information that an agent can use during execution. For example:Prompts and Tools
Tools allow agents to obtain information or perform actions through registered functions. For example:Prompts and Middleware
Middleware provides reusable behavior around agent execution. Prompts define model-facing behavioral guidance, while middleware handles application-level execution behavior. For example:Prompts in Workflows
When agents are used inside workflows, prompts can remain focused on the responsibility of the individual agent. For example:Prompts and Specialist Agents
Multi-agent systems benefit from role-specific instructions. For example:Prompts and Agent Delegation
When an agent delegates work to another agent, the delegated agent should have clear instructions defining its responsibility. For example:Prompt Organization
As a project grows, organize prompts by responsibility or domain. Example:Prompt Versioning
Prompts are application behavior and should therefore be version controlled alongside the application. When changing a prompt, consider whether the change affects:- Expected output
- Tool usage
- Safety behavior
- Agent responsibilities
- Workflow behavior
- Structured output
- Tests
Testing Prompts
Prompts can be tested by executing the agent against representative inputs. Useful test cases include:- Normal requests
- Missing information
- Unexpected input
- Tool-use scenarios
- Knowledge-retrieval scenarios
- Structured-output scenarios
- Error conditions
- Multi-agent handoffs
Prompt Size
Avoid placing large amounts of information directly into agent instructions. Large static instructions can make prompts harder to maintain and can consume model context unnecessarily. Prefer:- Prompts for behavior
- Conversation for conversational context
- Memory for persisted information
- Knowledge and retrieval for external information
- Tools for actions
- Workflow state for orchestration data
Provider Independence
BindAI provides a common agent interface across supported model providers. The same general prompt strategy can therefore be used while changing the configured model:Complete Example
A complete agent can combine reusable instructions with tools, memory, knowledge, and retrieval:Best Practices
- Keep instructions focused on the agent’s responsibility.
- Separate behavioral instructions from runtime data.
- Reuse common instructions where appropriate.
- Keep prompts in dedicated files or modules as applications grow.
- Version-control important prompts with the application.
- Clearly define expected output formats.
- Prefer structured output when application code requires a defined Python result.
- Keep large documents out of static instructions.
- Use tools for actions and external operations.
- Use memory for persisted information.
- Use knowledge and retrieval for external information.
- Use workflows for multi-step orchestration.
- Give specialist agents focused role-specific instructions.
- Test important prompts against the model providers the application supports.
- Treat significant prompt changes as application behavior changes.
